#{extends 'main.html' /}
#{set title:productRole.name /}
#{set 'crumbs'}
<li><a href="/show/projects"> Projects </a></li>
<li><a href="/show/project?id=${productRole.project.id}"> ${productRole.project.name} </a></li>
<li><a href="/projects/${productRole.project.id}/productroles"> Product Roles </a></li>
<li><a href="/productroles/${productRole.id}">${productRole.name}</a></li>
#{/set}
#{set 'moreLinks'}
#{if connected.in(project).can('editProductRole')}
#{if editable}
<p>
<a onclick="overlayOpen('/admin/productroles/${productRole.id}')"href="#"> Edit Product Role </a>
</p>
#{/if}
#{/if}

#{if connected.in(project).can('deleteProductRole')}
#{if deletable}
<p>
<a href = "#"  name="deleteProductRole" onclick="deleteProductRole()"> Delete Product Role </a>
</p>
#{/if}
#{/if}
#{/set}
#{if flash.success}
<p class="success" style="color:gray">&{flash.success}</p>
#{/if}

<h1>${productRole.name}</h1>

<h3> Description :</h3> 
 ${productRole.description}<br/><br/>

<h3> Project :</h3> 
${productRole.project}<br/><br/>

<h3> Stories including ${productRole.name}:</h3> 
<ul >
#{if !(noStories)}
#{list items:productRole.stories, as:'story'}
	#{if !story.deleted }
	<li>
		${story.description}
	</li> 
	#{/if}
#{/list}
#{/if}

#{if noStories}
   <p style="color:gray"> This product role is not included in any stories. </p>
#{/if}
</ul>
<br/><br/>
#{if editable}
#{if connected.in(project).can('editProductRole')}
<a onclick="overlayOpen('/admin/productroles/${productRole.id}')"href="#"><img src="@{'/public/images/famfam/pencil.png'}" title="Edit"></a>
#{/if}
#{/if}

#{if !(editable)}
   <p style="color:red"> *This Product role is included in some stories which are included in a current sprint, therefore it cannot be edited. </p>
#{/if}

#{if deletable}
#{if connected.in(project).can('deleteProductRole')}
<a onclick="deleteProductRole()"><img src="@{'/public/images/famfam/delete.png'}" title="Delete"></a>
#{/if}
#{/if}

#{if !(deletable)}
  <br/>
  <p style="color:red"> *This Product role is included in some stories, therefore it cannot be deleted. </p>
#{/if}
<br/>
<a href="/projects/${productRole.project.id}/productroles">Back to ${productRole.project.name} product roles</a>

<script type="text/javascript">
function deleteProductRole()
{
   	var id= ${productRole.id};
   	var confirmation= confirm("Are you sure you want to Delete Product Role?")
   	if (confirmation) {
   	   	$.post('@{deleteProductRole()}',{id:id},
    		function(){
   	   	window.location="/projects/${productRole.project.id}/productroles"
            });
   	}
	return false;
}
</script>


